/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('nbf', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model ApiTestRequest {
  testCmd?: string(name='testCmd'),
}

model ApiTestResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: string(name='body'),
}

async function apiTestWithOptions(request: ApiTestRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ApiTestResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.testCmd)) {
    query['testCmd'] = request.testCmd;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ApiTest',
    version = '2021-11-10_21-31-25-86',
    protocol = 'HTTPS',
    pathname = `/nbf_gateway_inner/1_0_0/apiTest`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'string',
  };
  return callApi(params, req, runtime);
}

async function apiTest(request: ApiTestRequest): ApiTestResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return apiTestWithOptions(request, headers, runtime);
}

model BuildSdkRequest {
  buildCmd?: string(name='buildCmd'),
}

model BuildSdkResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: string(name='body'),
}

async function buildSdkWithOptions(request: BuildSdkRequest, headers: map[string]string, runtime: Util.RuntimeOptions): BuildSdkResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.buildCmd)) {
    query['buildCmd'] = request.buildCmd;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'BuildSdk',
    version = '2021-11-10_21-31-25-86',
    protocol = 'HTTPS',
    pathname = `/nbf_gateway_inner/1_0_0/buildSdk`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'string',
  };
  return callApi(params, req, runtime);
}

async function buildSdk(request: BuildSdkRequest): BuildSdkResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return buildSdkWithOptions(request, headers, runtime);
}

model CreateAndReleaseApiRequest {
  creatApiCmd?: string(name='creatApiCmd'),
}

model CreateAndReleaseApiResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: string(name='body'),
}

async function createAndReleaseApiWithOptions(request: CreateAndReleaseApiRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateAndReleaseApiResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.creatApiCmd)) {
    query['creatApiCmd'] = request.creatApiCmd;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateAndReleaseApi',
    version = '2021-11-10_21-31-25-86',
    protocol = 'HTTPS',
    pathname = `/nbf_gateway_inner/1_0_0/createAndReleaseApi`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'string',
  };
  return callApi(params, req, runtime);
}

async function createAndReleaseApi(request: CreateAndReleaseApiRequest): CreateAndReleaseApiResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createAndReleaseApiWithOptions(request, headers, runtime);
}

model CreateSdkVersionRequest {
  createSdkCmd?: string(name='createSdkCmd'),
}

model CreateSdkVersionResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: string(name='body'),
}

async function createSdkVersionWithOptions(request: CreateSdkVersionRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateSdkVersionResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.createSdkCmd)) {
    query['createSdkCmd'] = request.createSdkCmd;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateSdkVersion',
    version = '2021-11-10_21-31-25-86',
    protocol = 'HTTPS',
    pathname = `/nbf_gateway_inner/1_0_0/createSdkVersion`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'string',
  };
  return callApi(params, req, runtime);
}

async function createSdkVersion(request: CreateSdkVersionRequest): CreateSdkVersionResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createSdkVersionWithOptions(request, headers, runtime);
}

model DeleteApiRequest {
  apiExternalId?: string(name='apiExternalId'),
}

model DeleteApiResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: string(name='body'),
}

async function deleteApiWithOptions(request: DeleteApiRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DeleteApiResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.apiExternalId)) {
    query['apiExternalId'] = request.apiExternalId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteApi',
    version = '2021-11-10_21-31-25-86',
    protocol = 'HTTPS',
    pathname = `/nbf_gateway_inner/1_0_0/deleteApi`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'string',
  };
  return callApi(params, req, runtime);
}

async function deleteApi(request: DeleteApiRequest): DeleteApiResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteApiWithOptions(request, headers, runtime);
}

model GetResultRequest {
  taskId?: string(name='taskId'),
}

model GetResultResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: string(name='body'),
}

async function getResultWithOptions(request: GetResultRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetResultResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.taskId)) {
    query['taskId'] = request.taskId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetResult',
    version = '2021-11-10_21-31-25-86',
    protocol = 'HTTPS',
    pathname = `/nbf_gateway_inner/1_0_0/getResult`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'string',
  };
  return callApi(params, req, runtime);
}

async function getResult(request: GetResultRequest): GetResultResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getResultWithOptions(request, headers, runtime);
}

model OpenApiGenericProxyResponseBody = {
  data?: string(name='data'),
}

model OpenApiGenericProxyResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: OpenApiGenericProxyResponseBody(name='body'),
}

async function openApiGenericProxyWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): OpenApiGenericProxyResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'OpenApiGenericProxy',
    version = '2021-11-10_21-31-25-86',
    protocol = 'HTTPS',
    pathname = `/nbf_gateway_inner/1_0_0/openApiGenericProxy`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function openApiGenericProxy(): OpenApiGenericProxyResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return openApiGenericProxyWithOptions(headers, runtime);
}

model PreCheckRequest {
  apiSchemaDTO?: string(name='apiSchemaDTO'),
  groupVersionExtraInfo?: string(name='groupVersionExtraInfo'),
  namespaceExternalId?: string(name='namespaceExternalId'),
}

model PreCheckResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: string(name='body'),
}

async function preCheckWithOptions(request: PreCheckRequest, headers: map[string]string, runtime: Util.RuntimeOptions): PreCheckResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.apiSchemaDTO)) {
    query['apiSchemaDTO'] = request.apiSchemaDTO;
  }
  if (!Util.isUnset(request.groupVersionExtraInfo)) {
    query['groupVersionExtraInfo'] = request.groupVersionExtraInfo;
  }
  if (!Util.isUnset(request.namespaceExternalId)) {
    query['namespaceExternalId'] = request.namespaceExternalId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'PreCheck',
    version = '2021-11-10_21-31-25-86',
    protocol = 'HTTPS',
    pathname = `/nbf_gateway_inner/1_0_0/preCheck`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'string',
  };
  return callApi(params, req, runtime);
}

async function preCheck(request: PreCheckRequest): PreCheckResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return preCheckWithOptions(request, headers, runtime);
}

model PublishSdkRequest {
  taskId?: string(name='taskId'),
}

model PublishSdkResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: string(name='body'),
}

async function publishSdkWithOptions(request: PublishSdkRequest, headers: map[string]string, runtime: Util.RuntimeOptions): PublishSdkResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.taskId)) {
    query['taskId'] = request.taskId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'PublishSdk',
    version = '2021-11-10_21-31-25-86',
    protocol = 'HTTPS',
    pathname = `/nbf_gateway_inner/1_0_0/publishSdk`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'string',
  };
  return callApi(params, req, runtime);
}

async function publishSdk(request: PublishSdkRequest): PublishSdkResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return publishSdkWithOptions(request, headers, runtime);
}

model SerializeApiRequest {
  apiSchemaDTO?: string(name='apiSchemaDTO'),
  type?: string(name='type'),
}

model SerializeApiResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: string(name='body'),
}

async function serializeApiWithOptions(request: SerializeApiRequest, headers: map[string]string, runtime: Util.RuntimeOptions): SerializeApiResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.apiSchemaDTO)) {
    query['apiSchemaDTO'] = request.apiSchemaDTO;
  }
  if (!Util.isUnset(request.type)) {
    query['type'] = request.type;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SerializeApi',
    version = '2021-11-10_21-31-25-86',
    protocol = 'HTTPS',
    pathname = `/nbf_gateway_inner/1_0_0/serializeApi`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'string',
  };
  return callApi(params, req, runtime);
}

async function serializeApi(request: SerializeApiRequest): SerializeApiResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return serializeApiWithOptions(request, headers, runtime);
}

model UpdateAndReleaseApiRequest {
  updateApiCmd?: string(name='updateApiCmd'),
}

model UpdateAndReleaseApiResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: string(name='body'),
}

async function updateAndReleaseApiWithOptions(request: UpdateAndReleaseApiRequest, headers: map[string]string, runtime: Util.RuntimeOptions): UpdateAndReleaseApiResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.updateApiCmd)) {
    query['updateApiCmd'] = request.updateApiCmd;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UpdateAndReleaseApi',
    version = '2021-11-10_21-31-25-86',
    protocol = 'HTTPS',
    pathname = `/nbf_gateway_inner/1_0_0/updateAndReleaseApi`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'string',
  };
  return callApi(params, req, runtime);
}

async function updateAndReleaseApi(request: UpdateAndReleaseApiRequest): UpdateAndReleaseApiResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return updateAndReleaseApiWithOptions(request, headers, runtime);
}

